<!doctype html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>配置修改</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*" />
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" th:href="@{/static/css/font.css}">
    <link rel="stylesheet" th:href="@{/static/css/xadmin.css}">
    <script th:src="@{/static/layui/layui.js}" charset="utf-8"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script th:src="@{/static/js/html5.min.js}" charset="UTF-8" src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script th:src="@{/static/js/respond.min.js}" charset="UTF-8" src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="layui-layout-body">
<fieldset class="layui-elem-field layui-field-title">
    <legend>定时部署任务</legend>
</fieldset>
<div class="layui-form layui-form-pane">
    <div class="layui-form-item">
        <div class="layui-inline" >
            <div class="layui-form-label">定时任务名称</div>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" autocomplete="off" name="name" lay-verify="required">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline" >
            <div class="layui-form-label">执行类型</div>
            <div class="layui-input-inline">
                <select name="timer" class="layui-select" lay-verify="required" >
                    <option value=""></option>
                    <option value="ONE">执行一次</option>
                    <option value="DAY">每天执行</option>
                    <option value="WEEK">每周执行</option>
                    <option value="MONTH">每月执行</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-form-label">执行时间</div>
            <div class="layui-input-inline">
                <input type="text" lay-verify="required" name="startTime" class="layui-input" id="date">
            </div>
        </div>
    </div>
    <div class="layui-inline">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="submitTimer">点击新增</button>
        </div>
    </div>
</div>
</body>
<script th:inline="javascript">
    var ctx = [[@{/}]]
    var type = /*[[${type}]]*/    //获取model中的值
</script>
<script th:inline="none">
    layui.use(['layedit','laydate','form'], function(){
        var layer = layui.layer
            ,laydate = layui.laydate
            ,form = layui.form
            ,$ = layui.jquery;

        //执行一个laydate实例
        laydate.render({
            elem: '#date' //指定元素
            ,type: 'datetime'
            ,theme: 'grid'
        });

        //监听提交
        form.on('submit(submitTimer)', function(data){
            data.field.type = type.toUpperCase();
            console.log(JSON.stringify(data.field));
            layer.confirm('请确定是否创建定时任务',
                function(index, layero){
                    //按钮【按钮一】的回调
                    var indexLoad = layer.load(1);
                    $.ajax({
                        type: "POST",
                        url: ctx + "timer/insert",
                        contentType: "application/json", //必须有
                        data: JSON.stringify(data.field),
                        success: function (response) {
                            layer.close(indexLoad);
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                            //回调函数方法体
                            parent.layer.msg(response.msg);
                            parent.layui.table.reload('test');
                        }
                    });
                });
            return false;
        });

    });
</script>

</html>